/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.yonsei.iwb.smarttv.model.measure;

import com.hp.hpl.jena.rdf.model.Resource;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

/**
 *
 * @author Onlyjiny
 */
public class ResourceWeights extends Hashtable<Resource, Double> {
    
    private double MAX_COUNT;
    private Hashtable<Resource, Integer> upt;
    
    public ResourceWeights(){
    }
    
    /**
     * 리소스 카운트를 바탕으로 최대값을 찾음
     * @param upt user prefered resources and its numbers
     */
    public ResourceWeights(Hashtable<Resource, Integer> upt){
        this.upt = upt;
        this.MAX_COUNT = 0;
        Enumeration<Integer> e = upt.elements();
        while(e.hasMoreElements()){
            int count = e.nextElement();
            if(count > MAX_COUNT){
                MAX_COUNT = count;
            }
        }
    }
    
    /**
     * 현재 최대 Count 수를 넘는 경우 
     * @param rset count 수를 늘려야할 리소스 집합
     */
    public void updatePreferenceResourceWeight(Vector<Resource> rset){
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    public Hashtable<Resource, Integer> getPreferedResourceTable(){
        return this.upt;
    }
    
    @Override
    public String toString(){
        StringBuffer sb = new StringBuffer();        
        Enumeration<Resource> e = this.keys();
        while(e.hasMoreElements()){
            Resource r = e.nextElement();
            double weight = this.get(r);            
            sb.append(r.getLocalName()).append(" / ").append(weight).append("\n");            
        }        
        return sb.toString();
    }

}
